/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.hpvas.gui;

import edu.hpvas.gui.internalframe.IFSearch;
import edu.hpvas.gui.internalframe.OwnerInternalFrame;
import edu.hpvas.gui.internalframe.PetInternalFrame;
import edu.hpvas.gui.internalframe.VeterinarianInternalFrame;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/**
 *
 * @author raider
 */
public class MainFrame extends javax.swing.JFrame {

    
    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int anchoScreen=screenSize.width;int ancho=1024;
        int alto=600;
        setSize(ancho, alto);
        int altoScreen=screenSize.height;
        setBounds((anchoScreen-getWidth())/2,(altoScreen-getHeight())/2,ancho,alto);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TBTool = new javax.swing.JToolBar();
        BVeterinarian = new javax.swing.JButton();
        Separator1 = new javax.swing.JToolBar.Separator();
        BOwner = new javax.swing.JButton();
        Separator2 = new javax.swing.JToolBar.Separator();
        BPet = new javax.swing.JButton();
        Separator3 = new javax.swing.JToolBar.Separator();
        TFSearch = new javax.swing.JTextField();
        Separator4 = new javax.swing.JToolBar.Separator();
        CBSearchType = new javax.swing.JComboBox();
        Separator5 = new javax.swing.JToolBar.Separator();
        BSearch = new javax.swing.JButton();
        Separator6 = new javax.swing.JToolBar.Separator();
        BExit = new javax.swing.JButton();
        DDMain = new javax.swing.JDesktopPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("HPVAS - System");
        setResizable(false);

        TBTool.setFloatable(false);
        TBTool.setRollover(true);

        BVeterinarian.setText("Veterinarian");
        BVeterinarian.setFocusable(false);
        BVeterinarian.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BVeterinarian.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BVeterinarian.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BVeterinarianActionPerformed(evt);
            }
        });
        TBTool.add(BVeterinarian);
        TBTool.add(Separator1);

        BOwner.setText("Owner");
        BOwner.setFocusable(false);
        BOwner.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BOwner.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BOwner.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BOwnerActionPerformed(evt);
            }
        });
        TBTool.add(BOwner);
        TBTool.add(Separator2);

        BPet.setText("Pet");
        BPet.setFocusable(false);
        BPet.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BPet.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BPet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BPetActionPerformed(evt);
            }
        });
        TBTool.add(BPet);
        TBTool.add(Separator3);

        TFSearch.setColumns(25);
        TBTool.add(TFSearch);
        TBTool.add(Separator4);

        CBSearchType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Veterinarian", "Owner", "Pet" }));
        TBTool.add(CBSearchType);
        TBTool.add(Separator5);

        BSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/hpvas/resources/searchIcon.jpg"))); // NOI18N
        BSearch.setFocusable(false);
        BSearch.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BSearch.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSearchActionPerformed(evt);
            }
        });
        TBTool.add(BSearch);
        TBTool.add(Separator6);

        BExit.setText("Exit");
        BExit.setFocusable(false);
        BExit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BExit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BExitActionPerformed(evt);
            }
        });
        TBTool.add(BExit);

        getContentPane().add(TBTool, java.awt.BorderLayout.NORTH);

        DDMain.setForeground(new java.awt.Color(255, 255, 255));
        getContentPane().add(DDMain, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BExitActionPerformed
        dispose();
    }//GEN-LAST:event_BExitActionPerformed

    private void BPetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BPetActionPerformed
        PetInternalFrame pif=new PetInternalFrame();
        pif.setVisible(true);
        DDMain.removeAll();;
        DDMain.setVisible(false);
        DDMain.add(pif);
        DDMain.setVisible(true);
    }//GEN-LAST:event_BPetActionPerformed

    private void BOwnerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BOwnerActionPerformed
        OwnerInternalFrame oif=new OwnerInternalFrame();
        oif.setVisible(true);
        DDMain.removeAll();;
        DDMain.setVisible(false);
        DDMain.add(oif);
        DDMain.setVisible(true);
    }//GEN-LAST:event_BOwnerActionPerformed

    private void BSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSearchActionPerformed
        if (!TFSearch.getText().equals("")) {
            IFSearch ifs=new IFSearch(CBSearchType.getSelectedItem().toString(),TFSearch.getText());
            ifs.setVisible(true);
            DDMain.setVisible(false);
            DDMain.removeAll();
            DDMain.add(ifs);
            DDMain.setVisible(true);
            
        } else {
            JOptionPane.showMessageDialog(this, "Search terms cannot be blank","Search - Error",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_BSearchActionPerformed

    private void BVeterinarianActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BVeterinarianActionPerformed
        VeterinarianInternalFrame veterinarian = new VeterinarianInternalFrame();
        veterinarian.setVisible(true);
        DDMain.removeAll();;
        DDMain.setVisible(false);
        DDMain.add(veterinarian);
        DDMain.setVisible(true);
    }//GEN-LAST:event_BVeterinarianActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BExit;
    private javax.swing.JButton BOwner;
    private javax.swing.JButton BPet;
    private javax.swing.JButton BSearch;
    private javax.swing.JButton BVeterinarian;
    private javax.swing.JComboBox CBSearchType;
    private javax.swing.JDesktopPane DDMain;
    private javax.swing.JToolBar.Separator Separator1;
    private javax.swing.JToolBar.Separator Separator2;
    private javax.swing.JToolBar.Separator Separator3;
    private javax.swing.JToolBar.Separator Separator4;
    private javax.swing.JToolBar.Separator Separator5;
    private javax.swing.JToolBar.Separator Separator6;
    private javax.swing.JToolBar TBTool;
    private javax.swing.JTextField TFSearch;
    // End of variables declaration//GEN-END:variables
}
